package cn.piggy.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ObjectMapperUtil {

    private ObjectMapperUtil(){}
    private static volatile ObjectMapper objectMapper;

    public static ObjectMapper getObjectMapper(){
        if(objectMapper==null){
            synchronized (ObjectMapperUtil.class){
                if(objectMapper==null){
                    objectMapper = new ObjectMapper();
                    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
                }
            }
        }
        return objectMapper;
    }
}
